#ifndef __DBG_PRT_MACRO__ 
#define __DBG_PRT_MACRO__ 

#include "prt_level_def.h"

void DebugPrint(int ErrorLevel, const char *format, ... );
//void log_write(const char* strbuf);

#if 0
#ifdef __DBG_PRT__
#define dbg_file_line(msg...)\
    do{\
        { \
            printf(" %s:%s:%d;",__FILE__,__func__,__LINE__);\
            printf(msg);\
            printf(" \n");\
        } \
    }while(0)

#else
    #define dbg_file_line(fmt, ...)
#endif

#ifdef __DBG_PRT__
#define dbg_func_line(msg...)\
    do{\
        { \
            printf("%s:%d;",__func__,__LINE__);\
            printf(msg);\
            printf(" \n");\
        } \
    }while(0)

#else
    #define dbg_func_line(fmt, ...)
#endif

#ifdef __DBG_PRT__
#define dbg_prt(msg...)\
    do{\
        { \
            printf(msg);\
        } \
    }while(0)
#else
    #define dbg_prt(fmt, ...)
#endif

#ifdef __DBG_PRT__
#define dbg_rn_prt(msg...)\
    do{\
        { \
            printf(msg);\
            printf(" \n");\
        } \
    }while(0)
#else
    #define dbg_rn_prt(fmt, ...)
#endif

#ifdef __DBG_PRT__
#define dbg_hex_line(num,buf)\
    do{\
		printf("%s:%s:%d;\ndbg_hex_line=",__FILE__,__func__,__LINE__);\
		for(int i=0;i<(num);++i)\
		{\
			printf("%02X ",buf[i]);\
		}\
		printf(" \n");\
	}while(0)
#else
    #define dbg_hex_line(num,buf)
#endif

#ifdef __DBG_PRT__
#define dbg_hex_send(num,buf)\
    do{\
		printf("send;%08d:",num);\
		for(int i=0;i<(num);++i)\
		{\
			printf("%02X ",buf[i]);\
		}\
		printf(" \n");\
	}while(0)
#else
    #define dbg_hex_send(num,buf)
#endif

#ifdef __DBG_PRT__
#define dbg_hex_recv(num,buf)\
    do{\
		printf("recv;%08d:",num);\
		for(int i=0;i<(num);++i)\
		{\
			printf("%02X ",buf[i]);\
		}\
		printf(" \n");\
	}while(0)
#else
    #define dbg_hex_recv(num,buf)
#endif

#define DEBUG_TEST(Expression)    \
    do{    \
        /* PRT_LEVEL (Expression);*/ \
        printf("\n"); \
    }while(false)

#ifdef __DBG_PRT__
#define DEBUG_TEST_02(Expression) \
    do { \
          PRT_LEVEL (Expression);   \
        /* printf("\n");  */ \
                        \
    } while (false)
#else
    #define DEBUG_TEST_02(Expression)
#endif

#ifdef __DBG_PRT__
#define DBG_LEVEL_PRT(Expression) \
    do { \
          PRT_LEVEL (Expression);   \
        /* printf("\n");  */ \
                        \
    } while (false)
#else
    #define DBG_LEVEL_PRT(Expression)
#endif
#endif

#if 0
#define PRT_LEVEL(Expression)   __DBG_LEVEL_PRT__ Expression
#define __DBG_LEVEL_PRT__(PrintLevel, ...)              \
    do {                                             \

         DebugPrint(PrintLevel, ##__VA_ARGS__);      \
                                                    \
    } while (false)
//  #define PRT_LEVEL(Expression)   __DBG_LEVEL_PRT__ Expression
#endif

#if 0 
// ok
#define PRT_LEVEL(Expression)   __PRT_LEVEL Expression
#define __PRT_LEVEL(PrintLevel, ...)              \
    do {                                             \
        if(PrintLevel>=LOG_LEVEL)   \
        {  \
         printf("%s;%d\n",__func__,__LINE__);  \
         DebugPrint (PrintLevel, ##__VA_ARGS__);      \
        }                                             \
    } while (false)
//  #define _DEBUG(Expression)   __PRT_LEVEL Expression
#endif

#if 1
#define PRT_LEVEL(Expression)   __PRT_LEVEL Expression
#define __PRT_LEVEL(PrintLevel, ...)              \
    do {                                             \
        if(PrintLevel>=LOG_LEVEL)   \
        {  \
         printf("%s;%d\n",__func__,__LINE__);  \
         DebugPrint (PrintLevel, ##__VA_ARGS__);      \
        }                                             \
    } while (false)
//  #define _DEBUG(Expression)   __PRT_LEVEL Expression
#endif
//PRT_LEVEL( (LOG_RUN, "Invalid ndismgr handle, thread exit..\n") );

#ifndef MOD_DBG_LEVEL
    #define MOD_DBG_LEVEL   LOG_ZERO
#endif

#if (MOD_DBG_LEVEL <= LOG_DBG  )
#define PRT_HEX_DBG(num,buf)\
    do{\
        printf("%s;%s;%d;\n",__FILE__,__func__,__LINE__);\
		for(int i=0;i<(num);++i)\
		{\
			printf("%02X ",buf[i]);\
		}\
		printf("\n num=%d \n", num);\
        }while(0)
#else
    #define PRT_HEX_DBG(num,buf)
#endif

#if (MOD_DBG_LEVEL <= LOG_DBG  )
#define PRT_DBG(msg...)\
    do{\
        printf("%s;%s;%d;",__FILE__,__func__,__LINE__);\
        printf(msg);\
        printf("\n");\
    }while(0)
#else
    #define PRT_DBG(msg, ...)
#endif

#if (MOD_DBG_LEVEL <= LOG_INFO  )
#define PRT_INFO(msg...)\
    do{\
        printf("%s;%s;%d;",__FILE__,__func__,__LINE__);\
        printf(msg);\
        printf("\n");\
    }while(0)
#else
    #define PRT_INFO(msg, ...)
#endif

#if (MOD_DBG_LEVEL <= LOG_ERR  )
#define PRT_HEX_ERR(num,buf)\
    do{\
        printf("%s;%s;%d;\n",__FILE__,__func__,__LINE__);\
		for(int i=0;i<(num);++i)\
		{\
			printf("%02X ",buf[i]);\
		}\
		printf("\n num=%d \n", num);\
	}while(0)
#else
    #define PRT_HEX_ERR(num,buf)
#endif

#if (MOD_DBG_LEVEL <= LOG_ERR  )
#define PRT_ERR(msg...)\
    do{\
        printf("%s;%s;%d;",__FILE__,__func__,__LINE__);\
        printf(msg);\
        printf(" \n");\
    }while(0)
#else
    #define PRT_ERR(msg, ...)
#endif


#endif
 


